using Sedna.Core.Controller;
using Sedna.Core.Controller.Common;

namespace Sedna.Core.Controls.Actions
{
    class ValidateFieldLength : AbstractValidationAction
    {
        private int maxLength=0;
        private int minLength=0;

        public int MaxLength
        {
            set { maxLength = value;}
        }
        
        public int MinLength
        {
            set { minLength = value;}
        }
        
        protected override bool Validate(IExecutionContext executionContext, string validationValue)
        {
            if (maxLength > 0 && validationValue.Length>maxLength) return false;
            if (minLength > 0 && validationValue.Length < minLength) return false;
            return true;
        }

    }
}
